package com.molin.IOtest.FileTest;

import java.io.File;

public class Demo4 {
    public static void main(String[] args) {
//        method();
//        method2();
//        method3();
//        method6();
        File file=new File("D:\\");
        File files[]=file.listFiles();
        for (File file1 : files) {
            System.out.println(file1);
        }
        /*进入文件夹，获取该文件夹下的所有文件的File对象，并把这些File对象都放在一个数组中返回
        * 包括隐藏文件*/
    }

    public static void method6() {
        File file=new File("a.txt");
        File file2=new File("C:\\molin");
        System.out.println(file.getName());
        System.out.println(file2.getName());
    }

    public static void method3() {
        File file=new File("a.txt");
        boolean exists = file.exists();
        System.out.println(exists);
    }


    public static void method2() {
        File file=new File("C:\\molin");
        boolean directory1 = file.isDirectory();
        boolean file1 = file.isFile();
        System.out.println(directory1);
        System.out.println(file1);
    }

    public static void method() {
        File file=new File("C:\\molin\\a.txt");
        boolean directory1 = file.isDirectory();
        boolean file1 = file.isFile();
        System.out.println(directory1);
        System.out.println(file1);
    }
}
